#include "MoveTool.h"

#include "EditWidget.h"

#include <QDebug>

using namespace Editor;

MoveTool::MoveTool(Editor::EditWidget* w) : widget(w), isMoving(0)
{       }

void MoveTool::leftButtonPressed()
{
    movingItem = widget->getNearVertex(mousePos);
     isMoving = movingItem?true:false;    
}

void MoveTool::leftButtonReleased()
{
    isMoving = false;
}

void MoveTool::rightButtonPressed()
{       }

void MoveTool::rightButtonReleased()
{       }

void MoveTool::mouseMove(QPointF p)
{
    Tool::mouseMove(p);
    
    if(isMoving)
    {
        movingItem->vertex()->move(p.x(), p.y());
        emit sceneChanged();
    }
}
